package com.spddr.pmos.jpa;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Embeddable;

import org.joda.time.DateTime;

@Embeddable
public class EnergyCheckId implements java.io.Serializable {
	private static final long serialVersionUID = 1L;

	private DateTime occur;
	private long plant;

	public EnergyCheckId() {
	}

	public EnergyCheckId(DateTime occur, long plant) {
		this.occur = occur;
		this.plant = plant;
	}

	@Column(name = "occur", nullable = false, length = 16)
	@Convert(converter = cn.seqdata.jpa.converter.DateTimeConverter.class)
	public DateTime getOccur() {
		return this.occur;
	}

	public void setOccur(DateTime occur) {
		this.occur = occur;
	}

	@Column(name = "plant", nullable = false)
	public long getPlant() {
		return this.plant;
	}

	public void setPlant(long plant) {
		this.plant = plant;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((occur == null) ? 0 : occur.hashCode());
		result = prime * result + (int) (plant ^ (plant >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		EnergyCheckId other = (EnergyCheckId) obj;
		if (occur == null) {
			if (other.occur != null)
				return false;
		} else if (!occur.equals(other.occur))
			return false;
		if (plant != other.plant)
			return false;
		return true;
	}
}